import hashlib
import utils
import binascii
import json
from Crypto.Cipher import AES


SECRET = b'H8BgWv08QIvwGhJw'

if __name__ == '__main__':
    m = hashlib.md5()
    m.update(b'admin')
    result_json = utils.request(path='/fjadmin/login',
                                method='POST',
                                params={
                                    'name': 'admin',
                                    'password': m.hexdigest()
                                })
    print(result_json)
    e = binascii.a2b_base64(result_json['token'])
    print(e)
    iv = e[:16]
    print(iv)
    cipher = AES.new(SECRET, AES.MODE_CFB, iv)
    d = cipher.decrypt(e[16:]).decode()
    print(d)
    d2 = str.split(d, ',')
    print(d2)
